package com.kfm.pm;

import java.util.Date;

public enum Greetings2 {

    GREETING();

    private String message;

    Greetings2 () {
        Date date = new Date();
        int hour = date.getHours();
        if (hour > 6 && hour <= 10) {
            this.message = "早上好";
        } else if (hour > 10 && hour <= 14) {
            this.message = "中午好";
        } else if (hour > 14 && hour <= 18) {
            this.message = "下午好";
        } else if (hour > 18 && hour <= 23) {
            this.message = "晚上好";
        } else {
            this.message = "凌晨好";
        }
    }

    public String getMessage() {
        return message;
    }

}

class Test02 {

    public static void main(String[] args) {
        Greetings2 greeting = Greetings2.GREETING;
        System.out.println(greeting.getMessage());
    }
}
